<?php

namespace App\Providers;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        

        $pid = getmypid();
        Log::channel('sqllog')->debug("({$pid}) ==================== Access URI: " . \Request::url() . ' ====================');
        DB::listen(function ($query) use ($pid) {
            Log::channel('sqllog')->debug("({$pid}) [{$query->time}] >>> Query: " . $query->sql);
            $bindings = $query->bindings;
            if (!empty($bindings)) {
                Log::channel('sqllog')->debug("({$pid})     Bindings: " . json_encode($bindings));
            }
        });
    }
}
